package com.lihepeng.leecode.design_patten.single;

/**
 * 双重校验所单例模式
 * 基于懒汉模式进行修改
 *
 */
public class Sington2 {
    // 增加volatile 的作用是防止代码进行重排序 从而按照代码书写顺序进行执行
    private static volatile Sington2 sington2 =null;

    private Sington2() {
    }

    public  static  Sington2 getInstance(){
            if (sington2 ==null){
                synchronized (Sington2.class){
                    if (sington2 == null){
                        sington2 = new Sington2();
                    }
                }
            }

        return sington2;
    }
}
